<?php
    require_once 'classes/Login.php';
    require_once 'classes/JobPost.php';
    $Login = new Login;
    if(!$Login->verify())
    {
        header('Location:login.php');
    }
    $JobPost = new JobPost();
	$empID = 0;
	$jobID = $_GET['jobID'];
	$jobListing = $JobPost->getPost($jobID,$empID);
	$jobCat = $JobPost->getCategoryName($jobListing[2]);
	$country = $JobPost->getCountryName($jobListing[5]);
	$locations = $JobPost->getLocations($jobID);
	/*var_dump($jobListing);
	var_dump($jobCat);
	$tot = count($locations);
	var_dump($tot);
	var_dump($locations);*/
    include 'includes/header.inc.php';
?>
            <div id="form">
                <h1>Edit Existing Job Listing</h1>
                    <fieldset id="jobPostingForm">
                            <form id="jobPostForm" method="post" action="/sandbox1/previewPost.php">
                                    <input type="hidden" id="formName" name="formName" value="newJobPost"/>
                                    <p>
                                        <label for="jobTitle">Job Title: </label>
                                        <input type="text" name="jobTitle" id="jobTitle" class="input" value="<?php echo $jobListing[1]; ?>" style="width:450px;"/>
                                    </p>
                                    <p style="height:35px;">
                                        <?php echo $JobPost->getCategories('jobPost',$jobListing[2]); ?>
                                    </p>
                                    <p>
                                        <label for="decription">Job Description: </label>
                                        <textarea id="description" name="description" style="width:455px;"><?php echo $jobListing[3]; ?></textarea>
                                    </p>
                                    <p>
                                        <label for="salary">Job Salary: </label>
                                        <input type="text" name="salary" id="salary" class="input postjob" value="<?php echo $jobListing[4]; ?>" style="width:450px;"/>
                                    </p>
                                    <p style="height:35px;">
                                        <label for="hide">Hide: </label>
                                        <input type="checkbox" name="hideName" id="hideName" class="check"/><span>Company Name</span>
                                        <input type="checkbox" name="hideSalary" id="hideSalary" class="check"/><span>Salary</span>
                                    </p>
                                    
                                <p>
                                    <input type="submit" name="previewPost" id="previewPost" class="button" value="Update Job Info" />
                                </p>
                            </form>
                    </fieldset>
                   
                    
                    
                    <fieldset id="jobPostingForm">
                    	<legend>Current City, State</legend>
                    		<form><div align="left"><?php
                            for($n=0;$n<count($locations);$n++)
                            {
								if(count($locations) > 1){
								   echo '<img src="/sandbox1/media/images/spacer.png" width="200" />
								   		<a href="javascript:void(0);" id="removeLocation" title="Remove This Location">
                                   		<img src="/sandbox1/media/images/not.png" style="padding-right:5px;" /></a>&nbsp;&nbsp;';
								   echo '<font size="4">';
                                   echo $locations[$n][1];
                                   echo ', ';
                                   echo $JobPost->getStateName($locations[$n][2]);
                                   echo '</font><br/>';
								
								}
								else {
								   echo '<img src="/sandbox1/media/images/spacer.png" width="240" />';
								   echo '<font size="4">';
                                   echo $locations[$n][1];
                                   echo ', ';
                                   echo $JobPost->getStateName($locations[$n][2]);
                                   echo '</font><br/>';
								}
                            } ?>
                            	
                                 
                              
                            </div></form>
                    </fieldset>
                    
                     <fieldset id="jobPostingForm">
                     <legend>Add Location</legend>
                     	<form>
               
                        <div class="location">
                              <label for="location">Location: </label>
                              <div class="locationInner" style="text-align:left; margin-left:135px; width:400px;">
                              <label for="city1" style="width:40px;">City: </label>
                                <input type="text" name="city1" id="city1" class="input city">
                              </div>
                            	<?php echo $JobPost->getStatesList($jobListing[5]); ?>
                       </div>
                        <p>
                           <input type="submit" name="previewPost" id="previewPost" class="button" value="Add Location" />
                        </p>
                       </form>
                    </fieldset>
                     <div id="loading"><img src="/sandbox1/media/images/loader.gif" alt="Loading..." /></div>
                    <div id="feedback"></div>
            </div>
            
            		
           
<?php include 'includes/footer.inc.php'; ?>